Skip to content

Change fs strncpy to strlcpy to avoid losing'\0'#5108

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
DS-LK:master
Dec 30, 2021
Merged

Change fs strncpy to strlcpy to avoid losing'\0'#5108
xiaoxiang781216 merged 1 commit into
apache:masterfrom
DS-LK:master

Conversation

@DS-LK

@DS-LK DS-LK commented Dec 29, 2021

Copy link
Copy Markdown

Summary

strncpy does not end with'\0', stack overflow may occur during use. Report here: #5107

Impact

After strncpy is modified to strlcpy,'\0' will be automatically added at the end to avoid usage problems.

Testing

This modification does not affect the function.

@xiaoxiang781216

xiaoxiang781216 commented Dec 29, 2021

Copy link
Copy Markdown
Contributor

@DS-LK let's fix the style warning:

Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:607:10: error: Multiple data definitions
Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:877:16: error: Multiple data definitions
Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:941:16: error: Multiple data definitions
Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:942:14: error: Multiple data definitions
Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:943:16: error: Multiple data definitions

and fill the follow macros after https://github.com/apache/incubator-nuttx/blob/master/tools/nxstyle.c#L256-L277:

Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:927:12: error: Mixed case identifier found
Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:1099:16: error: Mixed case identifier found
Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:1543:13: error: Mixed case identifier found
Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:1941:11: error: Mixed case identifier found
Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:1942:11: error: Mixed case identifier found
Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:1953:8: error: Mixed case identifier found
Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:1974:42: error: Mixed case identifier found

@DS-LK

DS-LK commented Dec 29, 2021

Copy link
Copy Markdown
Author

@DS-LK let's fix the style warning:

Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:607:10: error: Multiple data definitions
Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:877:16: error: Multiple data definitions
Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:941:16: error: Multiple data definitions
Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:942:14: error: Multiple data definitions
Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:943:16: error: Multiple data definitions

and fill the follow macros after https://github.com/apache/incubator-nuttx/blob/master/tools/nxstyle.c#L256-L277:

Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:927:12: error: Mixed case identifier found
Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:1099:16: error: Mixed case identifier found
Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:1543:13: error: Mixed case identifier found
Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:1941:11: error: Mixed case identifier found
Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:1942:11: error: Mixed case identifier found
Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:1953:8: error: Mixed case identifier found
Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:1974:42: error: Mixed case identifier found

thank you. done.

Comment thread fs/binfs/fs_binfs.c Outdated
Comment thread fs/nfs/nfs_vfsops.c Outdated
Comment thread fs/nfs/rpc_clnt.c Outdated
Comment thread fs/nfs/rpc_clnt.c Outdated
Comment thread fs/rpmsgfs/rpmsgfs_client.c Outdated
Comment thread fs/vfs/fs_readlink.c Outdated
Comment thread fs/userfs/fs_userfs.c Outdated
Comment thread fs/userfs/fs_userfs.c Outdated
Comment thread fs/userfs/fs_userfs.c Outdated
Comment thread fs/userfs/fs_userfs.c Outdated
Comment thread fs/userfs/fs_userfs.c Outdated
Signed-off-by: zhouliang3 <zhouliang3@xiaomi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants